package com.mdc;


//import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

//@CacheConfig(cacheNames = "users")
public interface UserRepository extends JpaRepository<User, Long> {
	//@Cacheable
	@Cacheable(
			cacheNames = "users",
			key = "#p0",
			condition = "#p0.length() < 3")
	User findByName(String name);

	User findByNameAndAge(String name, Integer age);

	@Query("from User u where u.name=:name")
	User findUser(@Param("name") String name);
}
